<!DOCTYPE html>
<html lang="en">

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport"
		content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no" />
	<meta name="format-detection" content="telephone=no" />
	<meta name="format-detection" content="email=no" />
	<meta http-equiv="Pragma" content="no-cache" />
	<meta http-equiv="Cache-Control" content="no-cache" />
	<meta http-equiv="Expires" content="0" />
	<title>患者档案-生活方式</title>
	<!-- 引入 vant UI 组件库样式文件 -->
	<link rel="stylesheet" href="../../common/css/vant-index.css" />
	<style rel="stylesheet">
		body {
			background-color: #f9f8f9;
		}

		a {
			-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
		}

		a:-webkit-any-link {
			color: #eee;
		}

		.container {
			border: 1px solid #f5f5f5;
			box-shadow: -1px 5px 5px #ececec;
			border-radius: 10px;
			/* margin: 0.6rem; */
			padding: 0;
		}

		#sub-title {
			margin-top: 0.5rem;
			margin-bottom: 0.5rem;
			margin-left: 1rem;
		}

		.icon {
			display: inline-block;
			background-color: #E22E30;
			width: 0.5rem;
			height: 0.5rem;
			margin-right: 0.5rem;
		}

		.text {
			display: inline-block;
			font-size: 1.1rem;
			font-weight: 450;
			color: #555555;
		}

		#sport-list {
			margin-top: 0.2rem;
			font-size: 1rem;
			font-weight: 350;
			color: #8c8b8c;
			text-align: left;
		}

		.van-cell__value {
			flex: 2;
		}

		.van-cell-group--inset {
			margin: 0;
		}

		.tab-btn {
			margin: 0.2rem;
			height: 1.7rem;
			line-height: 1.7rem;
		}
	</style>
</head>

<body>
	<div id="app" v-cloak>
		<div class="container">
			<van-nav-bar title="生活方式" left-text="返回" left-arrow @click-left="onClickLeft" @click-right="onClickRight">
				<template #right>
					<van-icon name="wap-home-o" size="18" />
				</template>
			</van-nav-bar>
			<div id="sub-title">
				<div class="icon"></div>
				<div class="text">运动情况</div>
			</div>
			<van-cell-group inset>
				<van-cell>
					<template #title>
						<span class="custom-title">是否有运动</span>
					</template>
					<template #value>
						{{currentData.lifewaySport == 1 ? '有' :
						currentData.lifewaySport == 1 ? '无' : '--'}}
					</template>
				</van-cell>
				<van-cell>
					<template #title>
						<span class="custom-title">何时运动</span>
					</template>
					<template #value>
						{{currentData.exerciseOpporunity == 1 ? '空腹' :
						currentData.exerciseOpporunity == 2 ? '餐后' :
						currentData.exerciseOpporunity == 3 ? '不固定' :
						'--'}}
					</template>
				</van-cell>
				<van-cell>
					<template #title>
						<span class="custom-title">运动频率</span>
					</template>
					<template #value>
						{{currentData.exerciseFrequency == 1 ? '&gt;5次/周'
						: currentData.exerciseFrequency == 2 ? '3～4次/周' :
						currentData.exerciseFrequency == 3 ? '&lt;3次/周' :
						'--'}}
					</template>
				</van-cell>
				<van-cell>
					<template #title>
						<span class="custom-title">运动时长</span>
					</template>
					<template #value>
						{{currentData.exerciseDuration == 1 ? '&lt;20min' :
						currentData.exerciseDuration == 2 ? '20~60min' :
						currentData.exerciseDuration == 3 ? '&gt;60min' :
						'--'}}
					</template>
				</van-cell>
				<van-cell>
					<span class="custom-title">运动方式</span>
					<div id="sport-list" v-if="currentData.exerciseMode != null">
						轻度: {{currentData.exerciseMode.indexOf('1') !=
						-1?'步行':''}}
						{{currentData.exerciseMode.indexOf('2') !=
						-1?'做家务':''}}<br />
						中度: {{currentData.exerciseMode.indexOf('3') !=
						-1?'快走':''}}
						{{currentData.exerciseMode.indexOf('4') !=
						-1?'太极拳':''}}
						{{currentData.exerciseMode.indexOf('5') !=
						-1?'骑车':''}}
						{{currentData.exerciseMode.indexOf('6') !=
						-1?'羽毛球':''}}
						{{currentData.exerciseMode.indexOf('7') !=
						-1?'乒乓球':''}}<br />
						重度: {{currentData.exerciseMode.indexOf('8') !=
						-1?'舞蹈':''}}
						{{currentData.exerciseMode.indexOf('9') !=
						-1?'有氧健身操':''}}
						{{currentData.exerciseMode.indexOf('10') !=
						-1?'慢跑':''}}
						{{currentData.exerciseMode.indexOf('11') !=
						-1?'游泳':''}}
						{{currentData.exerciseMode.indexOf('12') !=
						-1?'骑车上坡':''}}<br />
						其他: {{currentData.exerciseModeOther}}
					</div>
				</van-cell>
			</van-cell-group>

			<div id="sub-title">
				<div class="icon"></div>
				<div class="text">饮酒情况</div>
			</div>
			<van-cell-group inset>
				<van-cell>
					<template #title>
						<span class="custom-title">是否有饮酒史</span>
					</template>
					<template #value>
						{{currentData.drinkingFrequency == 1 ? '无饮酒史' :
						currentData.drinkingFrequency == 2 ? '&lt;= 2次/周'
						: currentData.drinkingFrequency == 3 ? '> 2次/周' :
						'--'}}
					</template>
				</van-cell>

				<van-cell>
					<template #title>
						<span class="custom-title">红酒</span>
					</template>
					<template #value>
						{{currentData.redwine}} ml/次
					</template>
				</van-cell>
				<van-cell>
					<template #title>
						<span class="custom-title">白酒</span>
					</template>
					<template #value>
						{{currentData.whitewine}} ml/次
					</template>
				</van-cell>
				<van-cell>
					<template #title>
						<span class="custom-title">啤酒</span>
					</template>
					<template #value>
						{{currentData.yellowwine}} ml/次
					</template>
				</van-cell>
			</van-cell-group>

			<div id="sub-title">
				<div class="icon"></div>
				<div class="text">吸烟情况</div>
			</div>
			<van-cell-group inset>
				<van-cell>
					<template #title>
						<span class="custom-title">是否有吸烟史</span>
					</template>
					<template #value>
						{{currentData.smoking == 1 ? '无吸烟史' :
						currentData.smoking == 2 ? '有吸烟史' : '--'}}
					</template>
				</van-cell>
				<van-cell>
					<template #title>
						<span class="custom-title">吸烟频率</span>
					</template>
					<template #value>
						{{currentData.smokingAmount}} 支/天
					</template>
				</van-cell>
			</van-cell-group>

			<div id="sub-title">
				<div class="icon"></div>
				<div class="text">睡眠情况</div>
			</div>
			<van-cell-group inset>
				<van-cell>
					<template #title>
						<span class="custom-title">睡眠质量</span>
					</template>
					<template #value>
						{{currentData.sleepQuality == 1 ? '较好' :
						currentData.sleepQuality == 2 ? '一般' :
						currentData.sleepQuality == 3 ? '较差' : '--'}}
					</template>
				</van-cell>
			</van-cell-group>
		</div>
	</div>
</body>
<!-- 上线环境用 -->
<script src="../../common/js/vue.global.prod.js"></script>
<!-- 引入 UI 组件库 -->
<script src="../../common/js/vant.min.js"></script>
<!-- axios 接口调用 -->
<script src="../../common/js/axios.min.js"></script>
<script src="../../base.js"></script>

<script type="module">
	import {
		getAction,
		postAction,
		getUrl,
	} from "../../common/js/api/vue3-axios-utils.js";
	const PatientData = {
		data() {
			return {
				url: {
					getInfo: "/102/14/1021402",
					updateInfo: "/102/14/1021401",
				},
				currentData: {},
				patient_url: "../index.html?userid=",
			};
		},
		created() {
			this.getData().catch((error) => {
				console.log(error);
			});
		},
		methods: {
			async getData() {
				let patientId = localStorage.pid;

				this.patient_url = this.patient_url + patientId;

				let url =
					getUrl() + this.url.getInfo + "?patientId=" + patientId;

				const res = await getAction(url);

				if (res.data.success) {
					this.currentData = await res.data.result;

					// 数据处理
					if (this.currentData.exerciseMode != null)
						this.currentData.exerciseMode =
							this.currentData.exerciseMode.split(",");
				}
			},
			onClickLeft() {
				window.location.href = "../filesIndex.html";
			},
			onClickRight() {
				window.location.href =
					"../index.html?userid=" + localStorage.pid;
			},
		},
	};

	const app = Vue.createApp(PatientData);

	app.use(vant);

	// 通过 CDN 引入时不会自动注册 Lazyload 组件
	// 可以通过下面的方式手动注册
	app.use(vant.Lazyload);

	// 调用函数组件，弹出一个 Toast
	// vant.Toast("刷新成功");

	app.mount("#app");
</script>

</html>
